package com.lkm.app_ui.m.Imple.hsj522;

import com.lkm.app_ui.log.SystemLogger;



class SendReadBlockTask extends AbsCMDSendTask<Void, byte[]> {
    private int sectorIndex;
    private int blockIndex;



    public SendReadBlockTask(CardCircuitComSe cardCircuitCom, int sectorIndex, int blockIndex) {
        super(cardCircuitCom, SendReadBlockTask.class.getName(), !true);
        this.sectorIndex = sectorIndex;
        this.blockIndex = blockIndex;
    }

    @Override
    protected void receiveResult(ReadResponEntity respon, int requestContinueSendCount) {

        if (respon != null && respon.isSuccess()) {


            if(SystemLogger.HSJ522.isDebug)
                SystemLogger.HSJ522.onReadStr1_0(respon);


            complete(new InnerResponEntity<byte[]>().success(respon.getData(), ""));
        } else {
            complete(new InnerResponEntity<byte[]>().fail(null, ""));
        }
    }

    @Override
    protected CMDWriteData createDataEntity(int requestContinueSendCount) {
        return new CMDWriteData() {
            @Override
            public byte[] getData() {

                return new byte[]{(byte) ((sectorIndex * 4) + (blockIndex))};
            }

            @Override
            public byte getCmd() {
                return 0x22;
            }
        };
    }

}
